@import org.silkframework.rule.vocab.VocabularyProperty
@import org.silkframework.config.Prefixes

@*
* Shows details information for a vocabulary property.
*@
@(name: String, property: Option[VocabularyProperty], prefixes: Prefixes = Prefixes.default)

@property match {
  case Some(prop) => { @renderProperty(prop) }
  case None => { Property @name not found in target vocabularies. }
}

@renderProperty(prop: VocabularyProperty) = {
<div class="di-rule-grey-box">
  <div class="di-rule-property-header"><span class="di-rule-property-name">@renderPropertyName(prop)</span> (<span class="di-rule-property-domain">@renderPropertyDomain(prop)</span>, <span class="di-rule-property-range">@renderPropertyRange(prop)</span>)</div>
  <div class="di-rule-property-description">
    @renderPropertyDescription(prop)
  </div>
</div>
}

@renderPropertyName(prop: VocabularyProperty) = {
  @prop.info.label match {
    case Some(label) => { @label }
    case None => { no label }
  }
}

@renderPropertyDescription(prop: VocabularyProperty) = {
  @prop.info.description match {
    case Some(desc) => { @desc }
    case None => { no description }
  }
}

@renderPropertyDomain(prop: VocabularyProperty) = {
  @prop.domain match {
    case Some(domain) => { @prefixes.shorten(domain.info.uri) }
    case None => { (unspecified) }
  }
}

@renderPropertyRange(prop: VocabularyProperty) = {
  @prop.range match {
    case Some(range) => { @prefixes.shorten(range.info.uri) }
    case None => { (unspecified) }
  }
}